const { Sequelize } = require("sequelize");
const sequelize = require("../db/index")


module.exports = {
  list: (condition) => {
    let key = Object.keys(condition)[0];
    let value = condition[key];
    let sql = "";

    switch (key) {
      case "start_city":
        sql += 'select * from t_bus_city where is_delete=0 and start_city = "' + value + '"';
        break;
      case "end_city":
        sql += 'select * from t_bus_city where is_delete=0 and end_city = "' + value + '"';
        break;
      case "all_start":
        sql += 'select distinct start_city, bus_city_id from t_bus_city where is_delete=0';
        break;
      case "all_end":
        sql += 'select distinct end_city, bus_city_id from t_bus_city where is_delete=0';
        break;
      default:
        break;
    }
    return sequelize.query(sql, { type: Sequelize.SELECT })
  }
}
